#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    int longestMountain(vector<int>& A) {
        if (A.size() < 3) return 0;
        int start = 0, end = 0;
        int res = 0;
        while (end < A.size()) {
            start = end;
            if (end < A.size() - 1 && A[end] < A[end + 1]) {
                while (end < A.size() - 1 && A[end] < A[end + 1]) ++end;
                if (end < A.size()-1 && A[end+1] < A[end]) {
                    while (end < A.size()-1 && A[end+1] < A[end]) ++end;
                    res = max(res, end - start + 1);
                }
            }
            else
                ++end;
        }
        return res;
    }
};

//int main() {
//    vector<int> A = { 2, 1, 4, 7, 3, 2, 5 };
//    Solution sol;
//    sol.longestMountain(A);
//
//}